export type Pixel = {
    r: number,
    g: number,
    b: number,
    a: number
};

export const TRANSPARENT:Pixel = {
    r: 0,
    g: 0,
    b: 0,
    a: 0
};

export type Image = {
    width: number,
    height: number,
    pixels: Pixel[]
}

export function pixel(channels:number[]){
    const rgba = {
        r: channels[0],
        g: channels[1],
        b: channels[2],
        a: 255
    };
    if(channels.length>3){
        rgba.a = channels[3]
    }
    return rgba;
}

export function channels(pixel:Pixel){
    return [
        pixel.r,
        pixel.g,
        pixel.b,
        pixel.a
    ];
}
